package com.ruoyi.socket.screen;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.gams.domain.GamsUserQueue;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

@Data
public class UserQueueVO
{
    /**
     * 用户姓名
     */
    private String userName;

    /**
     * 业务名称
     */
    private String bussinessName;

    /**
     * 状态：1.取号 2.业务办理中 3.挂起 4.办理结束 9.过号
     */
    private String statusStr;

    /**
     * 排队号码
     */
    private String number;

    public static List<UserQueueVO> convertList(List<GamsUserQueue> list)
    {
        return list.stream().map(UserQueueVO::convert).collect(Collectors.toList());
    }

    public static UserQueueVO convert(GamsUserQueue queue)
    {
        UserQueueVO screenVO = new UserQueueVO();
        screenVO.setBussinessName(queue.getBussinessName());
        screenVO.setNumber(queue.getNumber());
        screenVO.setStatusStr(getStatusStr(queue.getStatus()));
        screenVO.setUserName(getName(queue.getUserName()));
        return screenVO;
    }

    //隐藏一个字
    public static String getName(String sourceName)
    {
        if (StringUtils.isEmpty(sourceName))
        {
            return "";
        }
        if (sourceName.length() > 2)
        {
            return sourceName.substring(0, 1) + "*" + sourceName.substring(2, 3);
        }
        else
        {
            return sourceName.substring(0, 1) + "*";
        }
    }

    //状态转中文
    public static String getStatusStr(Integer status)
    {
        switch (status)
        {
            case 1:
                return "排队中";
            case 2:
                return "办理中";
            case 3:
                return "挂起中";
            case 4:
                return "完成";
            default:
                return "其他";
        }
    }

}
